﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Zhuang.Utility.Common.DataBase;
using Zhuang.Model.Access;

namespace Zhuang.DAL.Access
{
    public class Sys_StringDAL
    {

        public string GetStringCN(string stringCode)
        {
            return GetStringCN(null,stringCode);
        }

        public string GetStringCN(string moduleType, string stringCode)
        {
            if (moduleType == null)
            {
                moduleType = "Sys";
            }

            string result = "";

            string strSql = @"Select StringCN from Sys_String where ModuleType='{0}' and StringCode='{1}'";

            strSql = string.Format(strSql,moduleType,stringCode);

            DataTable dt = OleDbHelper.Query(strSql).Tables[0];
            if (dt.Rows.Count < 1)
            {
                result = "--未找到记录--";
            }
            else if (dt.Rows.Count == 1)
            {
                result = dt.Rows[0]["StringCN"].ToString();
            }
            else
            {
                result = string.Format("--{0}条重复记录--",dt.Rows.Count);
            }

            return result;
        }

        public string GetStringEN(string stringCode)
        {
            return GetStringEN(null, stringCode);
        }

        public string GetStringEN(string moduleType, string stringCode)
        {
            if (moduleType == null)
            {
                moduleType = "Sys";
            }

            string result = "";

            string strSql = @"Select StringEN from Sys_String where ModuleType='{0}' and StringCode='{1}'";

            strSql = string.Format(strSql, moduleType, stringCode);

            DataTable dt = OleDbHelper.Query(strSql).Tables[0];
            if (dt.Rows.Count < 1)
            {
                result = "--Can't find records--";
            }
            else if (dt.Rows.Count == 1)
            {
                result = dt.Rows[0]["StringEN"].ToString();
            }
            else
            {
                result = string.Format("--{0} same records--", dt.Rows.Count);
            }

            return result;
        }

        public string Add(Sys_StringEntity sse)
        {
            string result = "";

            

            return result;
        }

    }
}
